<script>
	import {
		mapMutations,
		mapActions
	} from 'vuex'
	import {
		inputInviteCode
	} from '@/api/user'
	import {
		userShare,
		getConfig
	} from '@/api/app'
	import Cache from '@/utils/cache'
	import {
		strToParams,
		showModal,
		setTabbar
	} from '@/utils/tools'
	import {
		wxMnpLogin
	} from '@/utils/login'
	export default {
		globalData: {
			navHeight: ""
		},
		onLaunch: function(options) {
			uni.hideTabBar({
				animation: false
			})
			// 获取配置
			this.getConfigFun()

			this.getUser()
			// 获取分享
			this.getShareInfo()
			//获取系统信息
			this.getSystemInfo()
		},
		onShow: function(options) {

			//绑定邀请码
			this.bindCode(options)
		},
		onHide: function() {
			console.log('App Hide')
		},
		methods: {
			...mapMutations(['SETCONFIG']),
			...mapActions(['getUser']),
			getSystemInfo() {
				uni.getSystemInfo({
					success: res => {
						let {
							statusBarHeight,
							platform
						} = res;
						let navHeight;

						if (platform == 'ios' || platform == 'devtools') {
							navHeight = statusBarHeight + 44;
						} else {
							navHeight = statusBarHeight + 48;
						}
						this.globalData.navHeight = navHeight;

					},
					fail(err) {
						console.log(err);
					}

				});
			},
			async getShareInfo() {
				const {
					code,
					data
				} = await userShare()
				if (code == 1) {
					Cache.set('shareInfo', data)
				}

			},
			async getConfigFun() {
				try {
					const {
						code,
						data
					} = await getConfig()
					if (code == 1) {
						this.SETCONFIG(data)
						setTabbar()
						console.log(data);
					}
				} catch (e) {
					uni.showTabBar()
				}

			},
			bindCode(options) {
				let invite_code = options.query.invite_code || strToParams(decodeURIComponent(options.query.scene))
					.invite_code
				if (invite_code) {
					inputInviteCode({
						code: invite_code
					}).then(res => {
						if (res.code == -1) {
							Cache.set("INVITE_CODE", invite_code)
						}
					})
				}
			}
		}
	}
</script>

<style lang="scss">
	@import 'styles/base.scss';
	/*每个页面公共css */
	@import "components/uview-ui/index.scss";
page{
	background: #F6F9FB;
}
	.flex-row-flex-start {
		display: flex;
		flex-direction: row;
		align-items: center;
		justify-content: flex-start;
	}

	.flex-row-flex-start1 {
		display: flex;
		flex-direction: row;
		// align-items: center;
		justify-content: flex-start;
	}

	.flex-row-center {
		display: flex;
		flex-direction: row;
		align-items: center;
		justify-content: center;
	}

	.flex-column-center {
		display: flex;
		flex-direction: column;
		align-items: center;
		justify-content: center;
	}

	.flex-column-center1 {
		display: flex;
		flex-direction: column;
		// align-items: center;
		justify-content: center;
	}

	.flex-column-flex-start {
		display: flex;
		flex-direction: column;
		// align-items: center; 
		justify-content: flex-start;
	}

	.flex-column-flex-start1 {
		display: flex;
		flex-direction: column;
		align-items: center;
		justify-content: flex-start;
	}

	.flex-row-space-between {
		display: flex;
		flex-direction: row;
		align-items: center;
		justify-content: space-between;
	}

	.flex-row-space-around {
		display: flex;
		flex-direction: row;
		align-items: center;
		justify-content: space-around;
	}

	//平均分配
	.flex-column-space-evenly {
		display: flex;
		flex-direction: column;
		flex-wrap: wrap;
		justify-content: space-evenly;
		align-items: center;
		// justify-content: space-around;
	}

	.flex-column-space-between {
		display: flex;
		flex-direction: column;
		/* align-items: center; */
		justify-content: space-between;
	}

	.flex-row-flex-end {
		display: flex;
		flex-direction: row;
		align-items: center;
		justify-content: flex-end;
	}

	.flex-column-flex-end {
		display: flex;
		flex-direction: column;
		vertical-align: center;
		justify-content: flex-end;
	}


	.display-flex {
		display: flex;
	}

	.flex-direction-row {
		flex-direction: row;
	}

	.flex-direction-column {
		flex-direction: column;
	}

	.justify-content-flex-start {
		justify-content: flex-start;
	}

	.justify-content-center {
		justify-content: center;
	}

	.align-items-flex-start {
		align-items: flex-start;
	}

	.align-items-center {
		align-items: center;
	}

	.justify-content-space-between {
		justify-content: space-between;
	}

	.justify-content-flex-end {
		justify-content: flex-end;
	}

	.vertical-align-center {
		vertical-align: center;
	}

	.BGImage {
		position: fixed;
		width: 100%;
		height: 100%;
		top: 0;
		left: 0;
		z-index: -1;
	}

	.flex1 {
		flex: 1
	}

	.flex-wrap {
		flex-wrap: wrap;
	}

	/* 其他 */
	.relative {
		position: relative;
	}

	.absolute {
		position: absolute;
	}

	.fixed {
		position: fixed;
	}

	.fixed-top {
		position: fixed;
		top: 0;
		left: 0;
		right: 0;
		z-index: 99;
	}

	.fixed-bottom {
		position: fixed;
		bottom: 0;
		left: 0;
		right: 0;
		z-index: 99;
	}
	.footer {
	   
	   padding-bottom: calc(env(safe-area-inset-bottom) + 10px);
		// padding-bottom: env(safe-area-inset-bottom);
		
	}
	.bottomButton{
		font-size: 27rpx;
		font-family: PingFang SC-Medium, PingFang SC;
		font-weight: 500;
		color: #FFFFFF;
		margin: 28rpx;
		height: 86rpx;
		background: $base-color;
		border-radius: 11rpx 11rpx 11rpx 11rpx;
		opacity: 1;
	}
	.baseColor{
		color: $base-color;
	}
</style>